package git.soulbgm.common.resolver;

import org.apache.shiro.authz.Permission;
import org.apache.shiro.authz.permission.PermissionResolver;
import org.apache.shiro.authz.permission.WildcardPermission;

/**
 * @author SoulBGM
 * @version 1.0
 * @date 2019/10/14 14:08
 */
public class UrlPermissionResolver implements PermissionResolver {

    private boolean permission;

    public UrlPermissionResolver(boolean permission) {
        this.permission = permission;
    }

    @Override
    public Permission resolvePermission(String permissionString) {
        if (permissionString.startsWith("/")) {
            return new UrlPermission(permission ? permissionString : "/**");
        }
        return new WildcardPermission(permissionString);
    }
}
